#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <iomanip>
#include<sstream>
#include<math.h>
#include<fstream>
using namespace std;



class Day{

public:

	int day;
	int month;
	int isAvailable;
	int bookedRoom;

	Day(){
	}
	
	Day(int d, int mon, int isAvail, int booked){
		day = d;
		month = mon;
		isAvailable = isAvail;
		bookedRoom = booked;
	}

	int getDay(){
		return day;
	}

	int getMonth(){
		return month;
	}

	int getIsAvailable(){
		return isAvailable;
	}

	int getBooked(){
		return bookedRoom;
	}

	void setIsAvailable(int isAvail){
		isAvailable = isAvail;
	}

};

/*********************************************************************************************************/ 

class Calendar{

public: static const int MONTHS = 4;
	   static const int DAYS = 123;
	   Day* days[123];

public:
	
	void setCalendar(){

			for (int i = 1; i <= MONTHS; i++){
				if(i == 1){
					int y = 1;
					for (int x = 0; x < 31; x++){
						days[x] = new Day(y, i, 1, 0);
						y++;
					}
				}

				if(i == 2){
					cout << 1;
					int y = 1;
					for (int x = 31; x < 60; x++){
						days[x] = new Day(y, i, 1, 0);
						y++;
					}
				}

				if(i == 3){
					int y = 1;
					for (int x = 60; x < 92; x++){
						days[x] = new Day(y, i, 1, 0);
						y++;
					}
				}

				if(i == 4){
					int y = 1;
					for (int x = 92; x < 123; x++){
						days[x] = new Day(y, i, 1, 0);
						y++;
					}
				}
			}
	}

		int checkCalendar(int month, int d){
			for(int x = 0; x<123; x++){
				if ((days[x]->getMonth() == month) && (days[x]->getDay() == d)){
					if (days[x]->getIsAvailable() == 1){
						days[x]->setIsAvailable(0);
						return 1;
					}
				}
			}
		}

		void saveCalendar(){
			ofstream myfile;
			myfile.open ("example.txt");
			for(int y = 0; y < 123; y++){
			myfile << days[y]->getMonth() << " ";
			myfile << days[y]->getDay() << " ";
			myfile << days[y]->getIsAvailable() << " ";
			myfile << days[y]->getBooked() << " ";
			myfile << endl;
			}
			myfile.close();
		}
		
		void getCalendar(){
			string line;
			ifstream myfile ("example.txt");
			if (myfile.is_open())
			{
			while ( myfile.good() )
			{
			getline (myfile,line);
			cout << line << endl;
			}
			}
			else cout << "Unable to open file"; 
			myfile.close();
		}

};



/************************************************************************************************************/


class Room{
	
	int roomNumber;

	Room(int room){
		roomNumber = room;
	}

};


/*************************************************************************************************************/

int _tmain(int argc, _TCHAR* argv[])
{	
	string attendee;
	int month;
	int day;
	char scheduling;
	char again;
	Calendar calendar;


	cout << "enter name  ";
	cin >> attendee;
	calendar.setCalendar();
	while(true){
	cout << "are you scheduling a meeting?  ";
	cin >> scheduling;
	if (scheduling = 'Y' || 'y'){
		cout << "what month?  ";
		cin >> month;
		cout << "what day?  ";
		cin >> day;
		if(calendar.checkCalendar(month, day) == 1){
			cout << "date has been confirmed" << endl;}
		else{
			cout << "date is not avaialable" << endl;}
	}
	calendar.saveCalendar();
	calendar.getCalendar();
	}

	return 0;

}